package cn.com.cifi.mars.util;

import cn.com.cifi.mars.common.exception.MsgException;
import cn.com.cifi.mars.constant.CodeEnum;
import cn.com.cifi.mars.constant.WhetherEnum;
import cn.com.cifi.mars.entity.SignPlanVersionSupplyDetail;
import cn.com.cifi.mars.entity.SupplyPlanVersionDetail;

import java.math.BigDecimal;


/**
 * 类的拷贝工具类
 */
public class BeanCopyUtils {
    /**
     * 基于产品构成及下层供货详情生成产品构成签约计划供货详情
     * @param product 产品构成供货详情
     * @param bean 供货详情(产品构成/楼栋/车位/房源包)
     * @return
     */
    public static SignPlanVersionSupplyDetail getProductSignPlanVersionSupplyDetail(SupplyPlanVersionDetail product,SupplyPlanVersionDetail bean){
        if(null == product || null == bean){
            throw new MsgException(CodeEnum.SIGN_PLAN_VERSION_SUPPLY_DETAIL_ERROR);
        }
        SignPlanVersionSupplyDetail s=new SignPlanVersionSupplyDetail();
        //id;
        s.setId(UUIDUtils.create());
        //继承的供货版本明细的id supplyPlanId;
        s.setSupplyPlanId(product.getId());
        //供货计划版本id versionId;
        s.setVersionId(product.getVersionId());
        //父级id pid;
        s.setPid(product.getPid());
        //层级类型 type;
        s.setType(product.getType());
        //层级ID orgId;
        s.setOrgId(bean.getOrgId());
        //层级code orgCode;
        s.setOrgCode(product.getOrgCode());
        //层级名称 orgName;
        s.setOrgName(product.getOrgName());
        //产品构成父级编码 proProductCode;
        s.setProProductCode(product.getProProductCode());
        //产品构成父级名称g proProductType;
        s.setProProductType(product.getProProductType());
        //经营方式编码 businessType;
        s.setBusinessType(bean.getBusinessType());
        //经营方式名称 businessTypeName;
        s.setBusinessTypeName(bean.getBusinessTypeName());
        //装修方式编码 freeType;
        s.setFreeType(bean.getFreeType());
        //装修方式名称 freeTypeName;
        s.setFreeTypeName(bean.getFreeTypeName());
        //产品属性编码 proType;
        s.setProType(bean.getProType());
        //产品属性名称 proTypeName;
        s.setProTypeName(bean.getProTypeName());
        //均价 averagePrice;
        s.setAveragePrice(bean.getAveragePrice()==null?new BigDecimal(0):bean.getAveragePrice());
        //车位均价 averagePriceParking;
        s.setAveragePriceParking(bean.getAveragePriceParking()==null?new BigDecimal(0):bean.getAveragePriceParking());
        //房源均价 averagePriceHouse;
        s.setAveragePriceHouse(bean.getAveragePriceHouse()==null?new BigDecimal(0):bean.getAveragePriceHouse());
        //面积 saleArea;
        s.setSaleArea(bean.getSaleArea()==null?new BigDecimal(0):bean.getSaleArea());
        //套数/车位数 num;
        s.setNum(bean.getNum()==null?0:bean.getNum());
        //房源套数 roomNum;
        s.setRoomNum(bean.getRoomNum()==null?0:bean.getRoomNum());
        //车位数 parkingNum;
        s.setParkingNum(bean.getParkingNum()==null?0:bean.getParkingNum());
        //房源货值 houseCommodityValue;
        s.setHouseCommodityValue(bean.getHouseCommodityValue()==null?new BigDecimal(0):bean.getHouseCommodityValue());
        //不包含待售车位货值 notCommodityValue;
        s.setNotCommodityValue(bean.getNotCommodityValue()==null?new BigDecimal(0):bean.getNotCommodityValue());
        //达成率 achievingRate;
        s.setAchievingRate(bean.getAchievingRate()==null?new BigDecimal(0):bean.getAchievingRate());
        //供货日期（计划）supplyDate;
        s.setSupplyDate(bean.getSupplyDate());
        //供货实际-非车位套数 roomNumActual;
        s.setRoomNumActual(bean.getRoomNumActual()==null?0:bean.getRoomNumActual());
        //供货实际-车位套数 parkingNumActual;
        s.setParkingNumActual(bean.getParkingNumActual()==null?0:bean.getParkingNumActual());
        //供货实际-面积 areaActual;
        s.setAreaActual(bean.getAreaActual()==null?new BigDecimal(0):bean.getAreaActual());
        //供货实际-非车位均价 averagePriceHouseActual;
        s.setAveragePriceHouseActual(bean.getAveragePriceHouseActual()==null?new BigDecimal(0):bean.getAveragePriceHouseActual());
        //供货实际-车位均价 averagePriceParkingActual;
        s.setAveragePriceParkingActual(bean.getAveragePriceParkingActual()==null?new BigDecimal(0):bean.getAveragePriceParkingActual());
        //供货实际-非车位金额 houseCommodityValueActual;
        s.setHouseCommodityValueActual(bean.getHouseCommodityValueActual()==null?new BigDecimal(0):bean.getHouseCommodityValueActual());
        //供货实际-车位金额(不含未推售车位货值) notCommodityValueActual;
        s.setNotCommodityValueActual(bean.getNotCommodityValueActual()==null?new BigDecimal(0):bean.getNotCommodityValueActual());
        //供货实际-供货日期 supplyDateActual;
        s.setSupplyDateActual(bean.getSupplyDateActual());
        //供货实际-虚拟供货日期
        s.setSupplyTimeVirtual(bean.getSupplyTimeVirtual());
        //是否车位楼栋(0.否 1.是) isParking;
        s.setIsParking(bean.getIsParking());
        //是否删除(0.否 1.是) isDelete;
        s.setIsDelete(WhetherEnum.NO.getKey());
        //创建人员 createBy;
        s.setCreateBy(null);
        //创建时间 createTime;
        s.setCreateTime(null);
        //更新人员 updateBy;
        s.setUpdateBy(null);
        //更新时间 updateTime;
        s.setUpdateTime(null);
        return s;
    }

    /**
     * 拷贝供货计划详情
     * @param supplyPlanVersionDetail 供货详情（分期/组团）
     * @return
     */
    public static SignPlanVersionSupplyDetail getSignPlanVersionSupplyDetail(SupplyPlanVersionDetail supplyPlanVersionDetail){
        if(supplyPlanVersionDetail==null){
            throw new MsgException(CodeEnum.SIGN_PLAN_VERSION_SUPPLY_DETAIL_ERROR);
        }
        SignPlanVersionSupplyDetail s=new SignPlanVersionSupplyDetail();
        //id;
        s.setId(UUIDUtils.create());
        //继承的供货版本明细的id supplyPlanId;
        s.setSupplyPlanId(supplyPlanVersionDetail.getId());
        //供货计划版本id versionId;
        s.setVersionId(supplyPlanVersionDetail.getVersionId());
        //父级id pid;
        s.setPid(supplyPlanVersionDetail.getPid());
        //层级类型 type;
        s.setType(supplyPlanVersionDetail.getType());
        //层级ID orgId;
        s.setOrgId(supplyPlanVersionDetail.getOrgId());
        //层级code orgCode;
        s.setOrgCode(supplyPlanVersionDetail.getOrgCode());
        //层级名称 orgName;
        s.setOrgName(supplyPlanVersionDetail.getOrgName());
        //产品构成父级编码 proProductCode;
        s.setProProductCode(supplyPlanVersionDetail.getProProductCode());
        //产品构成父级名称g proProductType;
        s.setProProductType(supplyPlanVersionDetail.getProProductType());
        //均价 averagePrice;
        s.setAveragePrice(supplyPlanVersionDetail.getAveragePrice()==null?new BigDecimal(0):supplyPlanVersionDetail.getAveragePrice());
        //车位均价 averagePriceParking;
        s.setAveragePriceParking(supplyPlanVersionDetail.getAveragePriceParking()==null?new BigDecimal(0):supplyPlanVersionDetail.getAveragePriceParking());
        //房源均价 averagePriceHouse;
        s.setAveragePriceHouse(supplyPlanVersionDetail.getAveragePriceHouse()==null?new BigDecimal(0):supplyPlanVersionDetail.getAveragePriceHouse());
        //面积 saleArea;
        s.setSaleArea(supplyPlanVersionDetail.getSaleArea()==null?new BigDecimal(0):supplyPlanVersionDetail.getSaleArea());
        //套数/车位数 num;
        s.setNum(supplyPlanVersionDetail.getNum()==null?0:supplyPlanVersionDetail.getNum());
        //房源套数 roomNum;
        s.setRoomNum(supplyPlanVersionDetail.getRoomNum()==null?0:supplyPlanVersionDetail.getRoomNum());
        //车位数 parkingNum;
        s.setParkingNum(supplyPlanVersionDetail.getParkingNum()==null?0:supplyPlanVersionDetail.getParkingNum());
        //房源货值 houseCommodityValue;
        s.setHouseCommodityValue(supplyPlanVersionDetail.getHouseCommodityValue()==null?new BigDecimal(0):supplyPlanVersionDetail.getHouseCommodityValue());
        //不包含待售车位货值 notCommodityValue;
        s.setNotCommodityValue(supplyPlanVersionDetail.getNotCommodityValue()==null?new BigDecimal(0):supplyPlanVersionDetail.getNotCommodityValue());
        //达成率 achievingRate;
        s.setAchievingRate(supplyPlanVersionDetail.getAchievingRate()==null?new BigDecimal(0):supplyPlanVersionDetail.getAchievingRate());
        //供货日期（计划）supplyDate;
        s.setSupplyDate(supplyPlanVersionDetail.getSupplyDate());
        //供货实际-非车位套数 roomNumActual;
        s.setRoomNumActual(supplyPlanVersionDetail.getRoomNumActual()==null?0:supplyPlanVersionDetail.getRoomNumActual());
        //供货实际-车位套数 parkingNumActual;
        s.setParkingNumActual(supplyPlanVersionDetail.getParkingNumActual()==null?0:supplyPlanVersionDetail.getParkingNumActual());
        //供货实际-面积 areaActual;
        s.setAreaActual(supplyPlanVersionDetail.getAreaActual()==null?new BigDecimal(0):supplyPlanVersionDetail.getAreaActual());
        //供货实际-非车位均价 averagePriceHouseActual;
        s.setAveragePriceHouseActual(supplyPlanVersionDetail.getAveragePriceHouseActual()==null?new BigDecimal(0):supplyPlanVersionDetail.getAveragePriceHouseActual());
        //供货实际-车位均价 averagePriceParkingActual;
        s.setAveragePriceParkingActual(supplyPlanVersionDetail.getAveragePriceParkingActual()==null?new BigDecimal(0):supplyPlanVersionDetail.getAveragePriceParkingActual());
        //供货实际-非车位金额 houseCommodityValueActual;
        s.setHouseCommodityValueActual(supplyPlanVersionDetail.getHouseCommodityValueActual()==null?new BigDecimal(0):supplyPlanVersionDetail.getHouseCommodityValueActual());
        //供货实际-供货日期 supplyDateActual;
        s.setSupplyDateActual(supplyPlanVersionDetail.getSupplyDateActual());
        //供货实际-虚拟供货日期
        s.setSupplyTimeVirtual(supplyPlanVersionDetail.getSupplyTimeVirtual());
        //是否车位楼栋(0.否 1.是) isParking;
        s.setIsParking(supplyPlanVersionDetail.getIsParking());
        //是否删除(0.否 1.是) isDelete;
        s.setIsDelete(supplyPlanVersionDetail.getIsDelete());
        //创建人员 createBy;
        s.setCreateBy(null);
        //创建时间 createTime;
        s.setCreateTime(null);
        //更新人员 updateBy;
        s.setUpdateBy(null);
        //更新时间 updateTime;
        s.setUpdateTime(null);
        return s;
    }

}
